import {Component, OnInit} from '@angular/core';
import {Router, NavigationEnd} from "@angular/router";
import 'rxjs/add/operator/filter';

@Component({
    selector: 'app-content',
    templateUrl: './content.component.html',
    styleUrls: ['./content.component.css']
})
export class ContentComponent implements OnInit {

    pageTitle = '';

    pageDesc = '';

    constructor(public router: Router) {
        router.events
            .filter(event => event instanceof NavigationEnd)
            .subscribe((event: NavigationEnd) => {
                if (event.url === '/dashboard') {
                    this.pageTitle = 'DashBoard';
                    this.pageDesc = '总控后台';
                } else if (event.url.startsWith('/stock')) {
                    this.pageTitle = '股票信息管理';
                    this.pageDesc = '股票信息';
                } else if (event.url.startsWith('/news')) {
                    this.pageTitle = '新闻管理';
                    this.pageDesc = '新闻';
                } else if (event.url.startsWith('/advert')) {
                    this.pageTitle = '广告管理';
                    this.pageDesc = '广告';
                } else if (event.url.startsWith('/message')) {
                    this.pageTitle = '留言管理';
                    this.pageDesc = '留言';
                }
            });
    }

    ngOnInit() {
    }

}
